#ifndef _EDITOR_H_
#define _EDITOR_H_ 1
#include <iostream>
#include <string>
enum Position {
  HEAD,
  TAIL,
};
class Editor{
public:
  Editor():text(""){};
  Editor(std::string text){
    this->text = std::move(text);
  };
  inline void 
  add(Position pos,std::string content){
    if(pos == HEAD)
	text.insert(0,std::move(content));
    else if(pos == TAIL)
	text += std::move(content);
  };
  inline void 
  del(Position pos,int len){
    if(len <= 0) return;
    if(len > text.size()){
	text.clear(); 
	return;
    }
    if(pos == HEAD)
	text.erase(0,len);
    else if(pos == TAIL)
	text.erase(text.size()-len);
  };
  inline std::string
  get_text(){return text;};
  inline void
  set_text(std::string content){text = std::move(content);};
  inline void 
  display(){std::cout << text << std::endl;};
private:
  std::string text; 
};
#endif
